<html>
	<head>
	<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<LINK rev="stylesheet" media="screen" href="css.css" type="text/css" rel="stylesheet">
	<style>
		
	</style>
	</head> 
	<body>
	<div class="all">
	<?php 
		include ('include/conn.php'); 
		
		$everypage = 4 ; 
		$pagecount = "SELECT COUNT(*) FROM tab";
		$pageres=mysql_query($pagecount);
		$pagetotal=mysql_result($pageres,0,0);
		$pagenum=$pagetotal/$everypage;
		$pagenum=ceil($pagenum);
		$pagenow=1; 
		if(isset($_GET['page']) && $_GET['page'] )
		{ 
			$pagenow = intval($_GET['page']);
		
		}
		$nextpage=$pagenow+1;
		if($nextpage>=$pagenum)
		{
			$nextpage=$pagenum;
		}
		$prepage=$pagenow-1;
		if($prepage <1)
		{
			$prepage = 1;
		}
		$start =$everypage*( $pagenow-1);

	?>
		
	<?php		
 
		
		echo '<div class="pagecontainer">';
		include ('include/config.php');
		echo	<<<cont
			一共有${pagetotal}条留言，每页显示 ${everypage}条，共${pagenum}页，当前第${pagenow}页  
			<br>
			<a href="?page=1">
			|<<首页 
			</a>
			<a href="?page=${prepage}">
			<<上页 
			</a>
			<a href="?page=${nextpage}">
			下页>> 
			</a>
			<a href="?page=${pagenum}">
			尾页>>|
			</a>
			</div>
cont;
			$sel="SELECT id,content,name,qq,time,ip FROM tab ORDER BY time DESC LIMIT $start, $everypage";
			$a=mysql_query($sel);
			
			while($i=mysql_fetch_object($a))
			{		
				echo "<div class='messagecontainer'>"; 
						echo "<div id='messagecontent'>主题：$i->content</div>";
						echo "<div id='name'>昵称：$i->name</div>";
						echo "<div id='qq'>QQ：$i->qq</div>";
						echo "<div id='time'>留言时间：$i->time</div>";
						echo "<div id='ip'>IP：$i->ip</div>";
				echo "</div>";
			}
		?>
	</body>
</html>